//
//  main.m
//  ArchiverDemo
//
//  Created by zhouxiaobo on 15/10/29.
//  Copyright © 2015年 mapath. All rights reserved.
//

#import <Foundation/Foundation.h>
#define PATH @"/Users/zhouxiaobo/Documents/Temps"

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        NSDictionary *dict = @{@"1":@"one",@"2":@"two",@"3":@"three"};
        
        //归档  - 将一个dict以2进制保存在文件里
//        NSData *data = [NSArchiver archivedDataWithRootObject:dict];
//        BOOL flag = [data writeToFile:[NSString stringWithFormat:@"%@/dic.plist",PATH] atomically:TRUE];
//        if (flag) {
//            NSLog(@"文件写入成功！");
//        }else{
//            NSLog(@"文件写入失败！");
//        }
        
        //解档
        NSData *data1 = [NSData dataWithContentsOfFile:[NSString stringWithFormat:@"%@/dic.plist",PATH]];
        id obj = [NSUnarchiver unarchiveObjectWithData:data1];
        NSLog(@"%@",obj);
        
        
    }
    return 0;
}
